package serial;

import java.io.*;

public class GoodsTest {
    public static void main(String[] args) {
        //定义Goods类对象
        Goods goods1=new Goods("gd001","电脑",8000);
        FileInputStream fis=null;
        FileOutputStream fos=null;
        BufferedOutputStream bos=null;
        ObjectOutputStream oos=null;
        ObjectInputStream ois=null;

        try {
            //fis=new FileInputStream("thread\\goods.txt");
            byte[] goodByte=goods1.toString().getBytes("utf-8");
            fos=new FileOutputStream("thread\\goods.txt");
            //oos=new ObjectOutputStream(fos);
            bos=new BufferedOutputStream(fos);
            bos.write(goodByte);
            //ois=new ObjectInputStream(fis);
            //oos.writeObject(goods1);
            //oos.flush();
            bos.flush();
            //Goods goods=(Goods)ois.readObject();
            //System.out.println(goods);
            fos.close();
            //oos.close();
            bos.close();
            //fis.close();
            //ois.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
